{include file="public/header"/}

<div id="container">
    <div id="page-header" class="am-cf">

        <div class="button">
            <a href="javascript:add()" class="am-btn am-btn-xs am-btn-primary" data-pjax><i class="am-icon-plus"></i>
                添加客服</a>
        </div>
    </div>
    <section class="panel" style="width: 98%;margin: 5px auto;">
        <table class="table">

            <thead>
            <tr>
                <th>用户名</th>
                <th>昵称</th>
                <th>客服分类</th>
                <th>网站id</th>
                <th>专属连接</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name='lister' id='admins'}
            <tr>
                <td>{$admins.user_name}</td>
                <td>{$admins.nick_name}</td>
                <td>{$admins.groupname}</td>
                <td>{$admins.business_id}</td>
                <td><input type="text" value="{$link}&groupid={$admins.groupid}&service_name={$admins.user_name}" style="width:30em" id="link-{$admins.user_name}"/>&nbsp;&nbsp;<a
                        href='javascript:copylink("link-{$admins.user_name}")' class='am-badge am-badge-primary'>复制</a></td>
                <td>
                    <a href='javascript:showinfo({$admins.json},{$group})' class='am-badge am-badge-primary'><i
                            class='am-icon-edit'></i> 编辑</a><a class="am-badge am-badge-success"
                                                               href='javascript:modify({$admins.service_id})'>修改密码</a><a
                        href='javascript:sdelete({$admins.service_id})' class='am-badge am-badge-danger'> <i
                        class='am-icon-recycle'></i> 删除</a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
        {$page}
    </section>
</div>

<script type="text/javascript">

    var sdelete = function (id) {

        layer.open({
            type: 1,
            title: '删除',
            area: ['260px', '180px'],
            content: "<div><center><p style='font-size:15px;margin:33px auto;'>确定删除该用户</p></center></div>",
            btn: ['确定', '取消'],
            yes: function () {
                $.ajax({
                    url: "/admin/manager/delete",
                    type: "post",
                    data: {id: id},
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, {
                                time: 2000, end: function () {
                                    location.reload();
                                }
                            });
                        }
                    }
                });
            }
        });
    }


    function add() {
        layer.open({
            type: 2,
            title: '添加客服',
            area: ['800px', '600px'],
            content: '/admin/manager/add'
        });
    }

    function copylink(id) {
        var Input = $('#' + id);
        Input.focus();
        Input.select();
        try {
            document.execCommand('copy');
            layer.msg('复制成功', {time: 1000});
        } catch (e) {
            console.log(e);
            layer.msg('复制失败', {time: 1000});
        }
    }

</script>

{include file="public/footer"/}
